package main

import (
	"fmt"
	"unicode/utf8"
)

func main() {
	s := "我餴go语言"
	fmt.Println("字节长度", len(s))
	fmt.Println("----------------")
	l := 0
	for i, ch := range s {
		fmt.Printf("%d:%c ", i, ch)
		l++
	}

	fmt.Println("----------------")
	for i, ch := range []byte(s) {
		fmt.Printf("%d: %x", i, ch)
	}

	fmt.Println("----------------")
	count := 0
	for i, ch := range []rune(s) {
		fmt.Printf("%d:%c", i, ch)
		count++
	}
	fmt.Println()
	fmt.Println("字符串长度：", count)
	fmt.Println("字符串长度：", utf8.RuneCountInString(s))
}
